home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / JTools / Janim / decode.asm < prev    next >
Encoding:
Assembly Source File  |  1991-10-26  |  7.4 KB  |  249 lines

  1. \ JForth Port of Jim Kent's unvscomp.asm
  2. \ by Martin Kees
  3.  
  4. \ The original docs:
  5. \ unvscomp.asm  Copyright 1987 Dancing Flame all rights reserved.
  6. \
  7. \ This file contains a single function which is set up to be called from
  8. \ C.  Ie the parameters are on the stack instead of registers.
  9. \       decode_vkplane(in, out, linebytes)
  10. \ where in is a bit-plane's worth of vertical-byte-run-with-skips data
  11. \ and out is a bit-plane that STILL has the image from last frame on it.
  12. \ Linebytes is the number of bytes-per-line in the out bitplane, and it
  13. \ should certainly be noted that the external pointer variable ytable
  14. \ must be initialized to point to a multiplication table of
  15. \ 0*linebytes, 1*linebytes ... n*linebytes  before this routine is called.
  16. \ The format of "in":
  17. \   Each column of the bitplane is compressed separately.  A 320x200
  18. \   bitplane would have 40 columns of 200 bytes each.  The linebytes
  19. \   parameter is used to count through the columns, it is not in the
  20. \   "in" data, which is simply a concatenation of columns.
  21. \
  22. \   Each columns is an op-count followed by a number of ops.
  23. \   If the op-count is zero, that's ok, it just means there's no change
  24. \   in this column from the last frame.
  25. \   The ops are of three classes, and followed by a varying amount of
  26. \   data depending on which class.
  27. \       1. Skip ops - this is a byte with the hi bit clear that says how many
  28. \          rows to move the "dest" pointer forward, ie to skip. It is non-
  29. \          zero
  30. \       2. Uniq ops - this is a byte with the hi bit set.  The hi bit is
  31. \          masked down and the remainder is a count of the number of bytes
  32. \          of data to copy literally.  It's of course followed by the
  33. \          data to copy.
  34. \       3. Same ops - this is a 0 byte followed by a count byte, followed
  35. \          by a byte value to repeat count times.
  36. \   Do bear in mind that the data is compressed vertically rather than
  37. \   horizontally, so to get to the next byte in the destination (out)
  38. \   we add linebytes instead of one!
  39.  
  40. \   XOR version is for AnimBrush support
  41.  
  42. anew TASK-DECODE
  43.  
  44. \ A2 = OUT
  45. \ A0 = IN
  46. \ A3 = YTABLE
  47. ASM DECODE_VKPLANE (  in out ytable --- , for anims )
  48.     movem.l    a2/a3/d5,-(rp)  ; save registers 
  49.     move.l    (dsp)+,a2
  50.     adda.l  a4,a2              \ a2 = absaddr bitmap
  51.     move.l    (dsp)+,a0
  52.     adda.l  a4,a0              \ a0 = absaddr delta plane data
  53.     move.l    d7,a3
  54.     adda.l  a4,a3              \ a3 = absaddr of ytable data
  55.     move.l  (a3),d2            \ d2 = linebytes
  56.     move.w    d2,d4    \ make a copy of linebytes to use as a counter
  57.     bra    1$    \ And go to the "columns" loop
  58.     
  59. 2$:    move.l    a2,a1     \ get copy of dest pointer
  60.     clr.w    d0      \ clear hi byte of op_count
  61.     move.b    (a0)+,d0  \ fetch number of ops in this column
  62.     bra    3$      \ and branch to the "op" loop.
  63.  
  64. 4$:    clr.w    d1      \ clear hi byte of op
  65.     move.b    (a0)+,d1  \ fetch next op
  66.     bmi    5$        \ if hi-bit set branch to "uniq" decoder
  67.     beq     6$      \ if it's zero branch to "same" decoder
  68.  
  69.               \ otherwise it's just a skip
  70.     add.w    d1,d1      \ use amount to skip as index into word-table
  71.     adda.w    0(a3,d1.w),a1
  72.     dbra.w    d0,4$     \ go back to top of op loop
  73.     bra    7$        \ go back to column loop
  74.  
  75.                 \ here we decode a "vertical same run"
  76. 6$:    move.b    (a0)+,d1  \ fetch the count
  77.     move.b    (a0)+,d3  \ fetch the value to repeat
  78.     move.w    d1,d5     \ and do what it takes to fall into a "tower"
  79.     asr.w    #3,d5     \ d5 holds # of times to loop through tower
  80.     and.w    #7,d1     \ d1 is the remainder
  81.     add.w    d1,d1
  82.     add.w    d1,d1
  83.     neg.w    d1
  84.     jmp    34(pc,d1.w)    \ why 34?  8*size of tower
  85.                     \ instruction pair, but the extra 2's
  86.                     \ pure voodoo.
  87. 8$:    move.b    d3,(a1)
  88.     adda.w    d2,a1
  89.     move.b    d3,(a1)
  90.     adda.w    d2,a1
  91.     move.b    d3,(a1)
  92.     adda.w    d2,a1
  93.     move.b    d3,(a1)
  94.     adda.w    d2,a1
  95.     move.b    d3,(a1)
  96.     adda.w    d2,a1
  97.     move.b    d3,(a1)
  98.     adda.w    d2,a1
  99.     move.b    d3,(a1)
  100.     adda.w    d2,a1
  101.     move.b    d3,(a1)
  102.     adda.w    d2,a1
  103.     dbra.w    d5,8$
  104.     dbra.w    d0,4$
  105.     bra.l    7$
  106.  
  107.                           \ here we decode a "unique" run
  108. 5$:    and.b    #$7f,d1   \ setting up a tower as above....
  109.     move.w    d1,d5
  110.     asr.w    #3,d5
  111.     and.w    #7,d1
  112.     add.w    d1,d1
  113.     add.w    d1,d1
  114.     neg.w    d1
  115.     jmp    34(pc,d1.w)
  116. 9$:    move.b    (a0)+,(a1)
  117.     adda.w    d2,a1
  118.     move.b    (a0)+,(a1)
  119.     adda.w    d2,a1
  120.     move.b    (a0)+,(a1)
  121.     adda.w    d2,a1
  122.     move.b    (a0)+,(a1)
  123.     adda.w    d2,a1
  124.     move.b    (a0)+,(a1)
  125.     adda.w    d2,a1
  126.     move.b    (a0)+,(a1)
  127.     adda.w    d2,a1
  128.     move.b    (a0)+,(a1)
  129.     adda.w    d2,a1
  130.     move.b    (a0)+,(a1)
  131.     adda.w    d2,a1
  132.     dbra.w    d5,9$      \ branch back up to "op" loop
  133. 3$:     dbra.w    d0,4$      \ branch back up to "column loop"
  134.  
  135.     \  now we've finished decoding a single column
  136. 7$:    addq.l    #1,a2  \ so move the dest pointer to next column
  137. 1$:    dbra.w    d4,2$  \ and go do it again what say?
  138.     movem.l    (rp)+,a2-a3/d5
  139.     move.l  (dsp)+,d7
  140. end-code
  141.  
  142.  
  143. ASM DECODE_XORVKPLANE ( in out ytable --- , for animbrushes )
  144.     movem.l    a2-a3/d5,-(rp)  ; save registers 
  145.     move.l    (dsp)+,a2
  146.     adda.l  a4,a2            \ a2 = absaddr bitmap
  147.     move.l    (dsp)+,a0
  148.     adda.l  a4,a0            \ a0 = absaddr delta plane data
  149.         move.l  d7,a3
  150.         adda.l  a4,a3            \ a3 = absaddr of ytable data
  151.     move.l    (a3),d2          \ d2 = linebytes
  152.     move.w    d2,d4    \ make a copy of linebytes to use as a counter
  153.     bra    1$    \ And go to the "columns" loop
  154.     
  155. 2$:    move.l    a2,a1     \ get copy of dest pointer
  156.     clr.w    d0      \ clear hi byte of op_count
  157.     move.b    (a0)+,d0  \ fetch number of ops in this column
  158.     bra    3$      \ and branch to the "op" loop.
  159.  
  160. 4$:    clr.w    d1      \ clear hi byte of op
  161.     move.b    (a0)+,d1  \ fetch next op
  162.     bmi    5$        \ if hi-bit set branch to "uniq" decoder
  163.     beq     6$      \ if it's zero branch to "same" decoder
  164.  
  165.               \ otherwise it's just a skip
  166.     add.w    d1,d1      \ use amount to skip as index into word-table
  167.     adda.w    0(a3,d1.w),a1
  168.     dbra.w    d0,4$     \ go back to top of op loop
  169.     bra    7$        \ go back to column loop
  170.  
  171.               \ here we decode a "vertical same run"
  172. 6$:    move.b    (a0)+,d1  \ fetch the count
  173.     move.b    (a0)+,d3  \ fetch the value to XOR!!!!!!!!!!!!!!!
  174.     move.w    d1,d5     \ and do what it takes to fall into a "tower"
  175.     asr.w    #3,d5     \ d5 holds # of times to loop through tower
  176.     and.w    #7,d1     \ d1 is the remainder
  177.     add.w    d1,d1
  178.     add.w    d1,d1
  179.     neg.w    d1
  180.     jmp    34(pc,d1.w)          \ why 34?  8*size of tower
  181.                                      \ instruction pair, but the extra 2's
  182.                                      \ pure voodoo.
  183. 8$:    eor.b    d3,(a1)
  184.     adda.w    d2,a1
  185.     eor.b    d3,(a1)
  186.     adda.w    d2,a1
  187.     eor.b    d3,(a1)
  188.     adda.w    d2,a1
  189.     eor.b    d3,(a1)
  190.     adda.w    d2,a1
  191.     eor.b    d3,(a1)
  192.     adda.w    d2,a1
  193.     eor.b    d3,(a1)
  194.     adda.w    d2,a1
  195.     eor.b    d3,(a1)
  196.     adda.w    d2,a1
  197.     eor.b    d3,(a1)
  198.     adda.w    d2,a1
  199.     dbra.w    d5,8$
  200.     dbra.w    d0,4$
  201.     bra.l    7$
  202.  
  203.                           \ here we decode a "unique" run
  204. 5$:    and.b    #$7f,d1   \ setting up a tower as above....
  205.     move.w    d1,d5
  206.     asr.w    #3,d5
  207.     and.w    #7,d1
  208.     add.w    d1,d1
  209.         move.w  d1,-(dsp)
  210.     add.w    d1,d1
  211.         add.w   (dsp)+,d1
  212.     neg.w    d1
  213.     jmp    50(pc,d1.w)    \ offset is 8*6 +2 bytes for the uniq tower
  214. 9$:    move.b    (a0)+,d1
  215.         eor.b   d1,(a1)
  216.     adda.w    d2,a1
  217.     move.b    (a0)+,d1
  218.         eor.b   d1,(a1)
  219.     adda.w    d2,a1
  220.     move.b    (a0)+,d1
  221.         eor.b   d1,(a1)
  222.     adda.w    d2,a1
  223.     move.b    (a0)+,d1
  224.         eor.b   d1,(a1)
  225.     adda.w    d2,a1
  226.     move.b    (a0)+,d1
  227.         eor.b   d1,(a1)
  228.     adda.w    d2,a1
  229.     move.b    (a0)+,d1
  230.     eor.b   d1,(a1)
  231.     adda.w    d2,a1
  232.     move.b    (a0)+,d1
  233.     eor.b   d1,(a1)
  234.     adda.w    d2,a1
  235.     move.b    (a0)+,d1
  236.     eor.b   d1,(a1)
  237.     adda.w    d2,a1
  238.     dbra.w    d5,9$      \ branch back up to "op" loop
  239. 3$:     dbra.w    d0,4$      \ branch back up to "column loop"
  240.  
  241.     \  now we've finished decoding a single column
  242. 7$:    addq.l    #1,a2  \ so move the dest pointer to next column
  243. 1$:    dbra.w    d4,2$  \ and go do it again what say?
  244.     movem.l    (rp)+,a2-a3/d5
  245.     move.l  (dsp)+,d7
  246. end-code
  247.  
  248.